﻿using System;
using System.Globalization;
using System.Windows;

namespace Sidvall.UI.Wpf.Converters
{
    public class StringToVisibilityConverter : ValueToVisibilityConverterBase
    {
        #region Public Members

        #region VisibilityToValue

        protected override object VisibilityToValue(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (!(value is Visibility))
                return DependencyProperty.UnsetValue;
            switch ((Visibility)value)
            {
                case Visibility.Collapsed:
                case Visibility.Hidden:
                    if (!this.Not)
                    {
                        if (this.Collapsed)
                            return "Collapsed";
                        else
                            return "Hidden";
                    }
                    else
                    {
                        return "Visible";
                    }
                default:
                    if (!this.Not)
                    {
                        return "Visible";
                    }
                    else
                    {
                        if (this.Collapsed)
                            return "Collapsed";
                        else
                            return "Hidden";
                    }
            }
        }

        #endregion

        #endregion
    }
}
